// 字典管理模块-接口
import request from '@/util/request';

/**
 * 字典分页
 * @param {*} param 查询参数
 * @param {*} pageParam  分页参数
 * @returns 
 */
export function pages(param,pageParam){

    const data = {
        paramCode:param.paramCode,
        paramType:param.paramType,
        page:pageParam.page,
        size:pageParam.limit
    }
    return request({
        url:"/sys/param/pages",
        method:"GET",
        params: data
    });

}

/**
 * 字典（附表）-数据表分页查询
 * @param {*} param 
 * @param {*} pageParam 
 * @returns 
 */
export function infoPages(param,pageParam){

    const data = {
        paramID:param.paramID,
        page:pageParam.page,
        size:pageParam.limit
    }
    return request({
        url:"/sys/paraminfo/pages",
        method:"GET",
        params: data
    });

}

/**
 * 字典数据删除
 * @param {*} param 
 * @returns 
 */
export function deletes(param){

    const data = {
        paramIDs:param
    }
    return request({
        url:"/sys/param/delete",
        method:"DELETE",
        params: data
    });

}

/**
 * 添加字典数据
 * @param {*} param 
 * @returns 
 */
export function addParam(param){

    const data = {
        paramID:param.paramID,
        paramCode:param.paramCode,
        paramName:param.paramName,
        paramType:param.paramType,
        paramDesc:param.paramDesc
    }
    return request({
        url:"/sys/param/add",
        method:"POST",
        data: data
    });

}

/**
 * 修改字典数据
 * @param {*} param 
 * @returns 
 */
export function updateParam(param){

    const data = {
        paramID:param.paramID,
        paramCode:param.paramCode,
        paramName:param.paramName,
        paramType:param.paramType,
        paramDesc:param.paramDesc
    }
    return request({
        url:"/sys/param/update",
        method:"PUT",
        data: data
    });

}

/**
 * 添加字典-数据项目数据
 * @param {*} param 
 * @returns 
 */
export function addParamInfo(param){

    const data = {
        paramInfoID:param.paramInfoID,
        dataName:param.dataName,
        dataValue:param.dataValue,
        dataDesc:param.dataDesc,
        dataOrder:param.dataOrder,
        isUse:param.isUse,
        paramID:param.paramID
    }
    return request({
        url:"/sys/paraminfo/add",
        method:"POST",
        data: data
    });

}

/**
 * 修改字典-数据项目数据
 * @param {*} param 
 * @returns 
 */
export function updateParamInfo(param){

    const data = {
        paramInfoID:param.paramInfoID,
        dataName:param.dataName,
        dataValue:param.dataValue,
        dataDesc:param.dataDesc,
        dataOrder:param.dataOrder,
        isUse:param.isUse,
        paramID:param.paramID
    }
    return request({
        url:"/sys/paraminfo/update",
        method:"PUT",
        data: data
    });

}

/**
 * 查询字典数据通过字典code
 * @param {*} code 
 * @returns 
 */
export function getParamByCode(code){

    const data = {
        paramCode:code
    }
    return request({
        url:"/sys/param/getParamByCode",
        method:"GET",
        params: data
    });

}